﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GestionCompte.Enums;
using GestionCompte.Entity.Interfaces;

namespace GestionCompte.Entity
{
    public class OperationEntity : DataContainer
    {
        private EntityAccess.OperationEntity x;

        #region properties
        public int OperationNumber { get; set; }
        public DateTime OperationDate { get; set; }
        public double OperationAmount { get; set; }
        public OperationsType OperationType { get; set; }
        #endregion

        #region Constructor
        public OperationEntity()
        { throw new NotImplementedException("The default constructor is not authorized in this context."); }

        public OperationEntity(int operationNumber, DateTime operationDate, double operationAmount, OperationsType operationType)
        {
            if (operationNumber <= 0 || operationDate == null || operationDate == DateTime.MinValue || operationAmount <= 0 || operationType == null )
            { throw new ArgumentException("One or more arguments is/are null or have an incorrect value for the operationEntity Constructor"); }
            this.OperationNumber = operationNumber;
            this.OperationDate = operationDate;
            this.OperationAmount = operationAmount;
            this.OperationType = operationType;
        }

        public OperationEntity(EntityAccess.OperationEntity x)
        {
            this.x = x;
        }
        #endregion

        #region Methods 
        //Method implemented from the Interface DataContainer
        object DataContainer.MapToEntityDataModel()
        {
            EntityAccess.OperationEntity operation = new EntityAccess.OperationEntity();
            operation.Id = OperationNumber;
            operation.OperationAmount = OperationAmount;
            operation.OperationDate = OperationDate;
            operation.OperationType = OperationType.ToString();

            return operation;
        }
        #endregion
    }
}
